package org.example.day06;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.example.day06.service.IJobInfoService;
import org.example.day06.service.JobInfoServiceImpl;

import java.io.IOException;

@WebServlet(name = "Center2Servlet", value = "/Center2Servlet")
public class Center2Servlet extends HttpServlet {
    private IJobInfoService jobInfoService = new JobInfoServiceImpl();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=UTF-8");
        //查询数据库获取center2数据，封装成需要的数据格式
        //System.out.println("123");
        String jsonStr=jobInfoService.getCenter2Str();
        //直接响应json字符串
        response.getWriter().write(jsonStr);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        doGet(request, response);
    }
}
